/*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~
 *  utility functions
 *~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*/
function logging(s) {
  if (g_debug_enable) {console.log(s);}
}

/*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~
 *  following functions could deal with different browse. 
 *~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*~-*/
function util_get_screen_height() {
  return document.documentElement.clientHeight;
}

function util_get_screen_width() {
  return document.documentElement.clientWidth;
}

function util_close_window() {
  window.close();
}

function util_copy_to_clipboard(s) {
  /*if(window.clipboardData) {
    window.clipboardData.clearData();
    window.clipboardData.setData("Text", s);
  } else if(navigator.userAgent.indexOf("Opera") != -1) {
    window.location = s;
  } else if (window.netscape) {
    try {
       netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
    } catch (e) {
       alert("你使用的FF浏览器,复制功能被浏览器拒绝！请手动拷贝！");
    }
    var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
    if (!clip)
       return;
    var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
    if (!trans)
       return;
    trans.addDataFlavor('text/unicode');
    var str = new Object();
    var len = new Object();
    var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
    var copytext = s;
    str.data = copytext;
    trans.setTransferData("text/unicode",str,copytext.length*2);
    var clipid = Components.interfaces.nsIClipboard;
    if (!clip)
       return false;
    clip.setData(trans,null,clipid.kGlobalClipboard);
  }*/
}

function util_install_gears() {
  alert('需要安装Google Gears才能使用该功能，请点击确定安装。');
  location.href = 'http://gears.google.com/?action=install&message=安装Google Gears，在简单输入中启用更多功能。&return=http://ezkeypad.at-labs.co.cc';
}

function util_add_favorite() {
  if (document.all) {
    window.external.addFavorite('http://ezkeypad.at-labs.co.cc',$('title').html());
  }
  else if (window.sidebar) {
    window.sidebar.addPanel($('title').html(), 'http://ezkeypad.at-labs.co.cc', '');
  }
}
